<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      .title-red {
        color: red;
      }
      .big {
        font-size: 50px;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <!-- <h2 v-bind:class="show && 'title'">class的绑定</h2> -->

      <!-- class做了特殊的增强，允许我们写成对象或者数组 -->
      <!-- 对象的key是类名，value是变量或者表达式 -->
      <!-- <h2 :class="{ title: show, big: num > 0 }">class的绑定</h2> -->

      <!-- :class和class是可以一起存在的 -->
      <!-- 如果类名出现了连字符, 那么需要加上引号 -->
      <!-- <h2 :class="{ 'title-red': show }" class="big">class的绑定</h2> -->
      <h2 :class="styleObj" class="big">class的绑定</h2>
      <button v-on:click="show = !show">btn</button>
    </div>

    <script src="./lib/vue3.js"></script>
    <script>
      const app = Vue.createApp({
        data() {
          return {
            show: true,
            num: 0,
          };
        },
        computed: {
          styleObj() {
            return { "title-red": this.show };
          },
        },
      }).mount("#app");
    </script>
  </body>
</html>
